
// 提示框
function toast(msg) {
  wx.showToast({
    title: msg,
    mask: true,
    icon: 'none',
    duration: 1000
  });
}

//弹窗提示
function modal(msg, doSuccess) {
  wx.showModal({
    title: '温馨提示',
    content: msg,
    success: function (res) {
      if (typeof doSuccess == "function") {
        doSuccess(res);
      }
    }
  })
}

//显示loading
function showLoading(msg) {
  if (msg == null || msg == '') {
    msg = '努力加载中...';
  }
  wx.showLoading({
    title: msg,
    mask: true
  })
}

//隐藏loading
function hideLoading() {
  wx.hideLoading();
}

// 测试提示框，正式版不会显示
function testToast(msg) {
  if (getApp().globalData.debug) {
    wx.showToast({
      title: msg,
      mask: true,
      icon: 'success',
      duration: 2000
    });
  }
}

//打印日志
function log(msg) {
  if (getApp().globalData.debug) {
    console.log(msg)
  }
}

module.exports = {
  toast: toast, //消息提示框
  log: log, //日志打印
  testToast: testToast, // 测试提示框，正式版不会显示
  modal: modal, //弹窗提示
  showLoading: showLoading, //显示加载框
  hideLoading: hideLoading //隐藏加载框
}